package gui.ParkingLotManager;

import java.awt.Color;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.TitledBorder;

import control.LoginController;

import system.SystemTypes;
import system.VCP;
import javax.swing.JComboBox;
import javax.swing.JTextArea;
import javax.swing.JTextField;
/**
 * this class use to Quarter Report Screen
 * @author G8
 *
 */
public class QuarterReportScreen extends JPanel implements ActionListener{
	public JButton btnLogout;
	public JButton btnBack;
	private JButton buttonGenerate;
	/**
	 * Quarter Report Screen Constructor 
	 */
	public QuarterReportScreen(){
		super();
		initialize();
	}
	/**
	 * This method contains the view of the Panel
	 */
	private void initialize() {
		setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Quarter Report Menu", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
		setBackground(SystemColor.menu);
		setBounds(VCP.guiX,VCP.guiY,500,400);
		setLayout(null);
		VCP.frame.setBounds(this.getBounds());
		
		btnBack = new JButton("Back");
		btnBack.setIcon(new ImageIcon(QuarterReportScreen.class.getResource("/img/back.png")));
		btnBack.setSize(150, 30);
		btnBack.setBounds(281, 22, 102, 35);
		btnBack.addActionListener(this);
		add(btnBack);
		
		btnLogout = new JButton("Logout");
		btnLogout.setSize(150, 30);
		btnLogout.setBounds(393, 22, 78, 35);
		btnLogout.addActionListener(this);
		add(btnLogout);
		
		JLabel lblContent = new JLabel("Report Content:");
		lblContent.setBounds(69, 105, 131, 14);
		add(lblContent);
		
		JTextArea textAreaReportContent = new JTextArea();
		textAreaReportContent.setEditable(false);
		textAreaReportContent.setBounds(69, 130, 365, 151);
		add(textAreaReportContent);
		
		JButton buttonSend = new JButton("Send Report");
		buttonSend.setBounds(180, 292, 131, 35);
		buttonSend.addActionListener(this);
		add(buttonSend);
		
		buttonGenerate = new JButton("Generate Report");
		buttonGenerate.setBounds(69, 62, 131, 35);
		buttonGenerate.addActionListener(this);
		add(buttonGenerate);
	}
	/**
	 * This method listens to the buttons on the panel
	 * @param e is the buttons the user Click
	 */
	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == buttonGenerate){
			SystemTypes lotToReport = new SystemTypes(new String("Quarter Report"),null);
			
		}
		if (e.getSource() == btnBack){
			VCP.setScreen(this, VCP.prevScreen);
			VCP.prevScreen.setBounds(VCP.guiX,VCP.guiY,500,400);
			VCP.prevScreen.setLayout(null);
			VCP.frame.setBounds(VCP.prevScreen.getBounds());
		}
		if (e.getSource() == btnLogout){
			SystemTypes userToLogout = new SystemTypes(VCP.currentUser,null);
			boolean logoutRes = LoginController.LogOut(userToLogout);
			if (logoutRes)
				VCP.setGUI(0, this);
			else{
				JOptionPane.showMessageDialog(null, "Failed to logout!", "Error",
	                    JOptionPane.ERROR_MESSAGE);
			}
		}
	}
}
